/**
 * 
 */
$(document).ready(function(){
	
	function addgoodsinfo(){
		return $.ajax({ 
			 type : "POST", //提交方式 
			 url : "../../back/goods/addGoodsInfo",//路径 
			 data : { 
				"id":,
			    "name":name,
			    "describe":details,
			    "orgPrice":prise,
			    "menuName":prise_box,
			    "goodsImg":goodsImg,
			    "state":state,
			    "hotSign":hotSign,
				"disPrice":disPrice,
				"createDate":createDate
			  },//数据，这里使用的是Json格式进行传输 
			 success : function(obj) {//返回数据根据结果进行相应的处理 
				console.log(obj);
			    if ( obj.success ) { 
			    	 alert("添加成功");
			    } else { 
			    	 alert("添加失败");
			    } 
			 }
			  
		 }).promise();
	}


	$("#bt_goodsAdd").click(function(){
		$.when(addgoodsinfo());
		var name = $("#goodsName").val();
		var details = $("#goodsDetails").val();
		var prise = $("#goodsPrise").val();
		var prise_box = $("#meuntext option:selected").val();
		var goodsImg = $("#goodsImg").val();
		var goodsId = $("#goodsId").val();
		var state = $("#goodsState option:selected").val();
		var goodsTag = $("#goodsTag option:selected").val();
		var createDate1 = $("#createDate");
		if(goodsTag == "新品"){
//			console.log(1);
			var disPrice =1;
		}else{
			var disPrice = 0;
		}
		if(goodsTag == "热卖"){
//			console.log(2);
			var hotSign = 1;
		}else{
			var hotSign = 0;
		}
		
		console.log(name);
		console.log(details);
		console.log(prise);
		console.log(prise_box);
		console.log(goodsImg);
		console.log(state);
		console.log(goodsTag);
		console.log(disPrice);
		console.log(hotSign);
		var myDate = new Date();
		var year = myDate.getFullYear();
		var month = myDate.getMonth();
		var date = myDate.getDate();
		var hours = myDate.getHours();
		var minutes = myDate.getMinutes();
		var seconds = myDate.getSeconds();
		createDate1.html(year+"年"+(month+1)+"月"+date+"日"+hours+":"+minutes+":"+seconds);
		var createDate = createDate1.html();
		
	})
})	